package com.chucang.shucang.common.base.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.concurrent.TimeUnit;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/10/3 17:15
 * @description
 */
@AutoConfiguration
public class CaffeineConfig {
    @Bean
    public Cache<String, Object> caffeineCache() {
        return Caffeine.newBuilder()
                .expireAfterWrite(3, TimeUnit.HOURS)
                .initialCapacity(600)
                .maximumSize(6000)
                .build();
    }
}
